package managesystem;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class deleteStudCourseServlet extends HttpServlet{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public void doPost(HttpServletRequest req, HttpServletResponse resp){
		
		HttpSession session = req.getSession();
		Student currStud = (Student) session.getAttribute("currStud");
		String choice = (String) req.getParameter("courseChoice");
		currStud.deleteCourse(choice);
		StudentManager.add(currStud); // update in de datastore het Student object
		session.setAttribute("currStud",currStud);
		
		try {
			resp.sendRedirect("/index.jsp?id=ucp");
			session.setAttribute("message","The course "+choice+", is removed.");
		} catch (IOException e) {
			
			e.printStackTrace();
		}
	}

}
